package sort.client;

import java.util.ArrayList;
import java.util.Arrays;

import junit.framework.TestCase;
import sort.buddle.BuddleSort;
import sort.insert.InsertSort;
import sort.select.SelectSort;

import common.tools.Sort;

/**
 * @Author  zhr
 * @Date  2012-6-11
 */
public class SortClient extends TestCase {

	private static int[] array = new int[10];
	
	Sort sort = null;
	public void testBuddleSort(){
		sort = new BuddleSort(); 
		sort.doSort(array);
		sort.print(array);
	}
	public void testSelectSort(){
		sort = new SelectSort();
		sort.doSort(array);
		sort.print(array);
	}
	public void testInsertSort(){
		sort = new InsertSort();
		sort.doSort(array);
		sort.print(array);
	}
	public void testArraySort(){		
		ArrayList<Integer> list  = new ArrayList<Integer>();
		Integer[] array = new Integer[100000];
		for(int i=0;i<array.length;i++){
			int temp = (int)(Math.random()*100000);
			if(!list.contains(temp)){
				list.add(temp);				
			}
		}
		array = (Integer[])list.toArray(new Integer[0]);
		long t1 = System.currentTimeMillis();
		Arrays.sort(array);
		long t2 = System.currentTimeMillis();
		System.out.println("execute completed!used time:"+(t2-t1));
		for(int i=0;i<100;i++){
			System.out.print(array[i]+",");
		}
	}
}
